<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 | 个人博客</title>
    <!-- Bootstrap 4 CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/style.css">
    <!-- Bootstrap JS 依赖 -->
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.6.0.js"></script>
    <script src="${pageContext.request.contextPath}/static/bootstrap/js/bootstrap.js"></script>
    <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3a0ca3;
            --accent-color: #4cc9f0;
            --light-color: #f8f9fa;
            --dark-color: #212529;
            --success-color: #2ecc71;
            --warning-color: #ff9e00;
        }

        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            position: relative;
        }

        /* 装饰元素 */
        .circle {
            position: absolute;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.1);
            z-index: 1;
        }

        .circle-1 {
            width: 300px;
            height: 300px;
            top: -100px;
            right: -100px;
        }

        .circle-2 {
            width: 200px;
            height: 200px;
            bottom: -80px;
            left: -80px;
        }

        .circle-3 {
            width: 150px;
            height: 150px;
            top: 40%;
            left: 10%;
        }

        .login-container {
            position: relative;
            z-index: 10;
            max-width: 450px;
            width: 100%;
            padding: 20px;
        }

        .login-card {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            overflow: hidden;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
            transform: translateY(0);
            transition: transform 0.3s, box-shadow 0.3s;
        }

        .login-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
        }

        .card-header {
            background: var(--primary-color);
            color: white;
            text-align: center;
            padding: 30px 20px;
            position: relative;
        }

        .card-header h2 {
            margin: 0;
            font-weight: 600;
            font-size: 28px;
        }

        .card-header p {
            opacity: 0.9;
            margin-bottom: 0;
        }

        .brand-logo {
            width: 80px;
            height: 80px;
            background: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 20px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .brand-logo i {
            font-size: 40px;
            color: var(--primary-color);
        }

        .card-body {
            padding: 30px;
        }

        .form-group {
            margin-bottom: 25px;
            position: relative;
        }

        .form-control {
            height: 50px;
            border-radius: 8px;
            padding-left: 45px;
            border: 1px solid #e1e5eb;
            transition: all 0.3s;
        }

        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 0.2rem rgba(67, 97, 238, 0.25);
        }

        .input-icon {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #adb5bd;
            font-size: 18px;
        }

        .form-check-label {
            color: #6c757d;
        }

        .btn-login {
            background: var(--primary-color);
            border: none;
            color: white;
            height: 50px;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            letter-spacing: 1px;
            transition: all 0.3s;
            text-transform: uppercase;
        }

        .btn-login:hover {
            background: var(--secondary-color);
        }

        .btn-login:active {
            transform: translateY(2px);
        }

        .divider {
            position: relative;
            text-align: center;
            margin: 25px 0;
            color: #6c757d;
        }

        .divider::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 0;
            width: 100%;
            height: 1px;
            background: #e1e5eb;
            z-index: 1;
        }

        .divider span {
            display: inline-block;
            background: white;
            padding: 0 15px;
            position: relative;
            z-index: 2;
        }

        .social-login {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-bottom: 25px;
        }

        .social-btn {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 20px;
            transition: all 0.3s;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        }

        .social-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 7px 15px rgba(0, 0, 0, 0.15);
        }

        .social-btn.google {
            background: #dd4b39;
        }

        .social-btn.facebook {
            background: #3b5998;
        }

        .social-btn.twitter {
            background: #1da1f2;
        }

        .card-footer {
            background: #f8f9fa;
            padding: 20px;
            text-align: center;
            border-top: 1px solid #e1e5eb;
        }

        .card-footer a {
            color: var(--primary-color);
            text-decoration: none;
            transition: all 0.3s;
            font-weight: 500;
        }

        .card-footer a:hover {
            color: var(--secondary-color);
            text-decoration: underline;
        }

        .error-message {
            color: #e74c3c;
            font-size: 14px;
            margin-top: 5px;
            display: none;
        }

        /* 响应式调整 */
        @media (max-width: 576px) {
            .login-container {
                padding: 15px;
            }

            .card-body {
                padding: 20px;
            }

            .card-header {
                padding: 20px 15px;
            }

            .brand-logo {
                width: 70px;
                height: 70px;
            }

            .brand-logo i {
                font-size: 35px;
            }
        }

        /* 动画效果 */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .login-card {
            animation: fadeIn 0.6s ease-out;
        }
    </style>
</head>
<body>
<!-- 背景装饰元素 -->
<div class="circle circle-1"></div>
<div class="circle circle-2"></div>
<div class="circle circle-3"></div>

<div class="login-container">
    <div class="login-card">
        <div class="card-header">
            <h2>欢迎回来</h2>
            <p>登录您的账户以继续</p>
        </div>

        <div class="card-body">
            <form id="loginForm" method="post" action="${pageContext.request.contextPath}/user/login">
                <div class="form-group">
                    <i class="fas fa-envelope input-icon"></i>
                    <input type="text" name="username" class="form-control" id="email" placeholder="用户名" required>
                    <div class="error-message" id="emailError">用户名有错</div>
                </div>

                <div class="form-group">
                    <i class="fas fa-lock input-icon"></i>
                    <input type="password" name="password" class="form-control" id="password" placeholder="密码" required>
                    <div class="error-message" id="passwordError">密码长度至少为6个字符</div>
                </div>

                <div class="form-group d-flex justify-content-between align-items-center">
                    <div class="form-check">
                        <input type="checkbox" name="" class="form-check-input" id="rememberMe">
                        <label class="form-check-label" for="rememberMe">记住我</label>
                    </div>
                    <%--<a href="#" class="text-primary">忘记密码?</a>--%>
                </div>

                <button type="submit" class="btn btn-login btn-block">登录</button>
            </form>
        </div>

        <div class="card-footer">
            <p>还没有账户? <a href="#">立即注册</a></p>
        </div>
    </div>
</div>

<script>
    // 表单验证
    document.getElementById('loginForm').addEventListener('submit', function(e) {
        e.preventDefault();

        const password = document.getElementById('password').value;
        const passwordError = document.getElementById('passwordError');

        let isValid = true;

        passwordError.style.display = 'none';


        // 验证密码
        if (password.length < 6) {
            passwordError.style.display = 'block';
            isValid = false;
        }

        if (isValid) {
            // 模拟登录过程
            const loginBtn = document.querySelector('.btn-login');
            loginBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 登录中...';
            loginBtn.disabled = true;
            $('#loginForm').submit();
        }
    });

    // 社交按钮悬停效果增强
    document.querySelectorAll('.social-btn').forEach(btn => {
        btn.addEventListener('mouseover', function() {
            this.style.transform = 'translateY(-3px)';
        });

        btn.addEventListener('mouseout', function() {
            this.style.transform = 'translateY(0)';
        });
    });
</script>
</body>
</html>
